<template>
  <div>
    <el-tag style="display: inline-block;vertical-align: top;">月份</el-tag>
    <el-date-picker
      type="monthrange"
      size="small"
      v-model="timeChange"
      :editable="false"
      :clearable="false"
      range-separator="~"
      value-format="yyyy-MM-dd"
      start-placeholder="开始月份"
      end-placeholder="结束月份"
      style="margin-left:-7px;"
      @change="getValue()"
    ></el-date-picker>
  </div>
</template>
<script>
export default {
  props: ["monthTime"],
  data() {
    const start = new Date();
    start.setMonth(start.getMonth() - 1);
    return {
      timeChange: this.monthTime.length>0?this.monthTime:[start, start], //改变dateTime的值，会报警告，这里重新定义变量赋值
    };
  },
  mounted() {
    this.getValue();
    console.log(this.monthTime,'weqeqe')
  },
  methods: {
    getValue() {
      this.$emit("monthClick", this.timeChange);
    }
  }
};
</script>
<style lang="scss" scoped>
.el-tag {
  background: #ffffff;
  border: 1px solid #dcdfe6;
}
</style>

